#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<assert.h>
#include<sys/types.h>
#include<sys/wait.h>
int main(int argc,char *argv[]){
    pid_t id = fork();
    assert(id != -1);

    if(id == 0){

        sleep(1);
        execvp(argv[1],&argv[1]);
        //execl("/usr/bin/lsaa","ls","--color=auto","-l","-a",NULL);
        //execlp("ls","ls","-a","-l",NULL);
        //char* argv[] = {(char*)"ls",
        //    (char*)"--color=auto",
        //    (char*)"-a",
        //    (char*)"-l",
        //    NULL};
        //execv("/usr/bin/ls",argv);
        //execvp("ls",argv);
        //char* envp_[] = {
        //    (char*)"MYENV=112233",
        //    NULL
        //};
        extern char** environ; 
        //execle("./mybin","mybin",NULL,envp_); 
        putenv((char*)"MYENV=999");
        execle("./mybin","mybin",NULL,environ); 
        exit(12);
    }
    int status = 0;
    printf("child process is running ...\n");
    pid_t ret = waitpid(id,&status,0);
    if(ret>0){
        printf("wait success,exit code:%d,signal:%d\n",(status>>8)&0xFF,status&0x7F);
    }

    return 0;
}
